package inter.model;

import inter.config.ResultStatus;

/**
 * 自定义返回结果
 * @author Max
 * @date 2016/10/24.
 */
public class ResultModel {

    /**
     * 返回码
     */
    private String returncode;

    /**
     * 返回结果描述
     */
    private String returnmsg;

    /**
     * 返回内容
     */
    private Object content;

    public Object getContent() {
        return content;
    }

    public ResultModel(String returncode, String returnmsg) {
        this.returncode = returncode;
        this.returnmsg = returnmsg;
        this.content = "";
    }

    public ResultModel(String returncode, String returnmsg, Object content) {
        this.returncode = returncode;
        this.returnmsg = returnmsg;
        this.content = content;
    }

    public ResultModel(ResultStatus status) {
        this.returncode = status.getReturncode();
        this.returnmsg = status.getReturnmsg();
        this.content = "";
    }

    public ResultModel(ResultStatus status, Object content) {
        this.returncode = status.getReturncode();
        this.returnmsg = status.getReturnmsg();
        this.content = content;
    }

    public static ResultModel ok(Object content) {
        return new ResultModel(ResultStatus.SUCCESS, content);
    }
    
    public static ResultModel no(Object content) {
        return new ResultModel(ResultStatus.FAILURE, content);
    }

    public static ResultModel ok() {
        return new ResultModel(ResultStatus.SUCCESS);
    }

    public static ResultModel error(ResultStatus error) {
        return new ResultModel(error);
    }

	public String getReturncode() {
		return returncode;
	}

	public void setReturncode(String returncode) {
		this.returncode = returncode;
	}

	public String getReturnmsg() {
		return returnmsg;
	}

	public void setReturnmsg(String returnmsg) {
		this.returnmsg = returnmsg;
	}
}